﻿using System.Diagnostics;

namespace WPFTestSolution.Utils;

public static class DotNetInstallCheckUtils {
    
    /**
     * 是否安装 .NET 8
     */
    public static bool IsDotNetInstalled() {
        try {
            using var process = new Process();
            process.StartInfo = new ProcessStartInfo {
                FileName = "dotnet",
                Arguments = "--list-runtimes",
                RedirectStandardOutput = true,
                CreateNoWindow = true,
                UseShellExecute = false
            };
            process.Start();
            string output = process.StandardOutput.ReadToEnd();
            return output.Contains("Microsoft.WindowsDesktop.App 8.");
        } catch {
            return false;
        }
    }

    public static void Go2DotNet8() {
        Process.Start(new ProcessStartInfo {
            FileName = "https://dotnet.microsoft.com/download/dotnet/8.0",
            UseShellExecute = true
        });
    }
}